| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkAstraeus::EffectManager Class Referencefinal

Manages the effects available in the component. More...

Inheritance diagram for nkAstraeus::EffectManager:

## Public Member Functions
Effect * | createOrRetrieve (nkMemory::StringView name, EFFECT_TYPE type)
Effect * | record (nkMemory::StringView name, nkMemory::UniquePtr< Effect > resource)
Effect * | get (nkMemory::StringView name)
Effect * | getByIndex (unsigned int id)
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName)
void | erase (nkMemory::StringView name)
nkMemory::UniquePtr< Effect > | relinquish (nkMemory::StringView name)

## Detailed Description

Manages the effects available in the component.

At all times, manager owns any memory allocated inside. External code should never delete memory returned by it.

## Member Function Documentation

## ◆ createOrRetrieve()

Effect* nkAstraeus::EffectManager::createOrRetrieve | ( | nkMemory::StringView | name,
|  | EFFECT_TYPE | type
| ) |  |

Creates if unavailable, or retrieves if available, an effect.

Depending on the parameter given for the type, the Effect instance retrieved will be :

Value | Pointer type
--- | ---
EFFECT_TYPE::ATMOSPHERE | AtmosphereEffect
EFFECT_TYPE::FILM_GRAIN | FilmGrainEffect
EFFECT_TYPE::FXAA | FxaaEffect
EFFECT_TYPE::IMAGE_ENVIRONMENT | ImageEnvironmentEffect
EFFECT_TYPE::SSAO | SsaoEffect
EFFECT_TYPE::TEXTURE_COPY | TextureCopyEffect
EFFECT_TYPE::TONE_MAPPING | ToneMappingEffect

To address it fully, casting is required. For instance :

FxaaEffect* effect = (FxaaEffect*)EffectManager::getInstance()->createOrRetrieve("effect", EFFECT_TYPE::FXAA) ;

Parameters

  name | The name of the effect to retrieve.
  type | The effect type to create.

Returns
  The effect requested, possibly freshly created. The manager owns the memory returned, external code should never delete it. See erase().

## ◆ record()

Effect* nkAstraeus::EffectManager::record | ( | nkMemory::StringView | name,
|  | nkMemory::UniquePtr< Effect > | resource
| ) |  |

Records an already existing resource in the manager, passing its ownership around.

Parameters

  name | The name under which the resource should be recorded.
  resource | The resource to record.

Returns
  A raw pointer over the resource, now recorded in the manager.

## ◆ get()

Effect* nkAstraeus::EffectManager::get | ( | nkMemory::StringView | name | ) |

Retrieves an effect.

Parameters

  name | The name of the effect to retrieve.

Returns
  The effect if available, nullptr else.

## ◆ getByIndex()

Effect* nkAstraeus::EffectManager::getByIndex | ( | unsigned int | id | ) |

Get an effect, by index. Note that one index can map to a different effect after memory is changed. Useful to loop over all available effects in one go.

Parameters

  id | The index of the effect to retrieve.

Returns
  The effect linked if available, nullptr else.

## ◆ rename()

void nkAstraeus::EffectManager::rename | ( | nkMemory::StringView | currentName,
|  | nkMemory::StringView | newName
| ) |  |

Renames an effect.

Parameters

  currentName | The name of the effect to rename.
  newName | The name to reassign to the effect.

## ◆ erase()

void nkAstraeus::EffectManager::erase | ( | nkMemory::StringView | name | ) |

Erases and frees an effect.

Parameters

  name | The name of the effect to erase.

## ◆ relinquish()

nkMemory::UniquePtr<Effect> nkAstraeus::EffectManager::relinquish | ( | nkMemory::StringView | name | ) |

Requests the manager to relinquish the ownership of a resource and pass it around.

Parameters

  name | The name of the recorded resource to relinquish.

Returns
  The ownership over the resource requested if available, nullptr otherwise.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsAstraeus/Graphics/Effects/EffectManager.h